//
//  HQYHomeTourView.m
//  Go!
//
//  Created by rimi on 16/7/8.
//  Copyright © 2016年 黄秋燕. All rights reserved.
//

#import "HQYHomeTourView.h"
#import "HQYHomePageViewController.h"
#import "HQYHomeRecommendDetailViewController.h"

@interface HQYHomeTourView ()
@property (nonatomic, strong) NSDictionary *dict; /**< plist文件数据字典 */
@property (nonatomic, strong) HQYHomeRecommendDetailViewController *detailVC; /**< 二级页面 */
@end

@implementation HQYHomeTourView

- (void)drawRect:(CGRect)rect{
    //获得文件路径(需要转换的plist文件)
    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"HQYHomeSelectShop.plist" ofType:nil];
    //将文件转换为数组
    _dict = [NSDictionary dictionaryWithContentsOfFile:filePath];
}


#pragma mark - 更多按钮监听
- (IBAction)clickedMoreButton:(UIButton *)sender {
    // 直接切换标签控制器
    [HQYHomePageViewController shareHomeVc].tabBarController.selectedIndex = 1;
}

#pragma mark - 著名景点按钮监听
- (IBAction)clickedFamousSpotBtn:(UIButton *)sender {
    [self publicButtonMethodWithDict:_dict[@"景点"] VcTitle:@"景点"];
}

#pragma mark - 走遍全国按钮监听
- (IBAction)clickedNationwideBtn:(UIButton *)sender {
    [self publicButtonMethodWithDict:_dict[@"国内游"] VcTitle:@"国内游"];
}

#pragma mark - 玩转地球按钮监听
- (IBAction)clickedEarthBtn:(UIButton *)sender {
    [self publicButtonMethodWithDict:_dict[@"境外游"] VcTitle:@"境外游"];
}

// 按钮公共点击方法，跳转二级页面
- (void)publicButtonMethodWithDict:(NSDictionary *)dict
                           VcTitle:(NSString *)title {
    self.detailVC = [[HQYHomeRecommendDetailViewController alloc] init];
    self.detailVC.shopsDict = dict;
    self.detailVC.title = title;
    [((UIViewController *)self.nextResponder.nextResponder.nextResponder).navigationController pushViewController:self.detailVC animated:YES];
}
@end
